package com.Oct_Seven;

public class Solution1723 {

    int ans=Integer.MAX_VALUE;

    public int minimumTimeRequired(int[] jobs, int k) {
        dfs(jobs,new int[k],0);
        return ans;
    }

    void dfs(int[] jobs,int[] sum,int index){
        if (index==jobs.length)
        {
            int max=Integer.MIN_VALUE;
            for (int a :
                    sum) {
                max = Math.max(max, a);
            }
            ans=max;
            return;
        }
        for (int i=0;i<sum.length;i++)
        {
            if (i>0&&sum[i]==sum[i-1]) continue;
            if (i>0&&index==0) break;
            sum[i]+=jobs[index];
            if (sum[i]<ans)
            {
                dfs(jobs,sum,index+1);
            }
            sum[i]-=jobs[index];
        }
    }

    public static void main(String[] args) {

    }
}
